#include <bits/stdc++.h>

using namespace std;

int b1, b2;

int graph[1001][1001] = {0};
int dir[8][2] = {-2, -1, -2, 1, -1, -2, -1, 2, 1, -2, 1, 2, 2, -1, 2, 1};

struct Knight
{
    int x;
    int y;
    int f;
    int g;
    int h;
};

struct Compare
{
    bool operator()(const Knight &a, const Knight &b)
    {
        return a.f > b.f;
    }
};

int calculate_distance(const Knight &k)
{
    return (k.x - b1) * (k.x - b1) + (k.y - b2) * (k.y - b2);
}

priority_queue<Knight, vector<Knight>, Compare> que;

void bfs(const Knight &knight)
{
    que.push(knight);
    Knight cur, next;
    while (!que.empty())
    {
        cur = que.top();
        que.pop();
        if (cur.x == b1 && cur.y == b2)
        {
            break;
        }
        for (int i = 0; i < 8; i++)
        {
            next.x = cur.x + dir[i][0];
            next.y = cur.y + dir[i][1];
            if (next.x <= 0 || next.x > 1000 || next.y <= 0 || next.y > 1000)
            {
                continue;
            }
            if (!graph[next.x][next.y])
            {
                next.g = cur.g + 5;
                next.h = calculate_distance(next);
                next.f = next.g + next.h;
                que.push(next);
                graph[next.x][next.y] = graph[cur.x][cur.y] + 1;
            }
        }
    }
}

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int a1, a2;
        cin >> a1 >> a2 >> b1 >> b2;
        memset(graph, 0, sizeof(graph));
        Knight knight;
        knight.x = a1;
        knight.y = a2;
        knight.h = calculate_distance(knight);
        knight.g = 0;
        knight.f = knight.g + knight.h;
        bfs(knight);
        while (!que.empty())
        {
            que.pop();
        }
        cout << graph[b1][b2] << endl;
    }
    return 0;
}